package org.csu.mybigpro.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.csu.mybigpro.domain.Score;
import org.csu.mybigpro.persistence.ScoreMapper;
import org.csu.mybigpro.service.ScoreService;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

@Service
public class ScoreServiceImpl extends ServiceImpl<ScoreMapper, Score> implements ScoreService {

    @Override
    public int addScore(Score score) {
        return baseMapper.insertScore(score);
    }

    @Override
    public Score getScoreById(Long id) {
        return baseMapper.getScoreById(id);
    }

    @Override
    public List<Score> getAllScores() {
        return baseMapper.getAllScores();
    }

    @Override
    public int updateScore(Score score) {
        return baseMapper.updateScore(score);
    }

    @Override
    public int deleteScore(Long id) {
        return baseMapper.deleteScoreById(id);
    }

    @Override
    public BigDecimal getAverageScoreByCourseId(Long courseId) {
        return baseMapper.getAverageScoreByCourseId(courseId);
    }

    @Override
    public Map<String, BigDecimal> getScoreDistribution(Long courseId) {
        return baseMapper.getScoreDistribution(courseId);
    }
}